extends PlayerState

# ===============================================

@export var speed: float

# ===============================================

func process(_delta: float) -> void:
	if player.control_scheme == Player.ControlScheme.CPU:
		# TODO AI movement
		pass
	else:
		var direction: Vector2 = KeyUtils.get_input_vector(player.control_scheme)
		player.velocity = direction * speed
		
		if player.velocity.x > 0:
			player.heading = Vector2.RIGHT
			player.player_sprite.flip_h = false
		elif player.velocity.x < 0:
			player.heading = Vector2.LEFT
			player.player_sprite.flip_h = true
		
		if player.velocity.length() > 0:
			player.animation_player.play("run")
		else:
			player.animation_player.play("idle")
		
		#if player.velocity != Vector2.ZERO and KeyUtils.is_action_just_pressed(player.control_scheme, KeyUtils.Action.SHOOT):
			#state_transition.emit(self, State.TACKLE)
			#return
		
		if player.has_ball() and KeyUtils.is_action_just_pressed(player.control_scheme, KeyUtils.Action.SHOOT):
			state_transition.emit(self, State.PREPARE_SHOOT)
		
		
